package org.example;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.example.domain.Student;
import org.example.util.MyBatisUtil;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

/**
 * @user:dell
 * @date:2020年10月22 10:13
 */
public class MyApp {
    public static void main(String[] args) throws IOException {
        SqlSession sqlSession = MyBatisUtil.getSqlSession();
        //5.执行 SqlSession 的 selectList()
        List<Student> studentList =sqlSession.selectList("org.example.dao.StudentDao.selectStudents");
        //6.循环输出查询结果
        for (Student student : studentList) {
            System.out.println(student);
        }
//        studentList.forEach( student -> System.out.println(student));
        //7.关闭 SqlSession，释放资源
        sqlSession.close();
    }

}
